package com.greateffect.littlebud.lib.utils;

/**
 * @Description
 * @Author kk20
 * @Date 2018/5/2
 * @Version V1.0.0
 */
public class ImageUtil {

    public static boolean isGif(String imgName) {
        String type = imgName.toLowerCase();
        int index = imgName.lastIndexOf(".");
        if (index != -1) {
            type = imgName.substring(index + 1).toLowerCase();
        }
        if (type.equalsIgnoreCase("gif")) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isImage(String imgName) {
        String type = imgName.toLowerCase();
        int index = imgName.lastIndexOf(".");
        if (index != -1) {
            type = imgName.substring(index + 1).toLowerCase();
        }
        if (type.equalsIgnoreCase("png") ||
                type.equalsIgnoreCase("jpg") ||
                type.equalsIgnoreCase("jpeg") ||
                type.equalsIgnoreCase("bmp") ||
                type.equalsIgnoreCase("webp")) {
            return true;
        } else {
            return false;
        }
    }

    public static boolean isAudio(String url) {
        String type = url.toLowerCase();
        int index = url.lastIndexOf(".");
        if (index != -1) {
            type = url.substring(index + 1).toLowerCase();
        }
        if (type.equalsIgnoreCase("mp3") || type.equalsIgnoreCase("amr")) {
            return true;
        } else {
            return false;
        }
    }
}
